package com.huajx.hanvon.handler;

import com.huajx.core.handler.HandlerAdapter;
import com.huajx.hanvon.Const;
import com.huajx.hanvon.HanvonTcpServer;
import com.huajx.util.map.MapUtil;
import org.apache.mina.core.session.IoSession;

import java.util.Map;

public abstract class AbstractHanvonHandler implements HandlerAdapter {

    protected Map<String, Object> getPara(IoSession session) {
        //获取设备序列号
        Object serialNumber = session.getAttribute(Const.KEY_SERIALNUMBER);
        String sn = String.valueOf(serialNumber);

        Map<String, Object> parameters = MapUtil.of("schoolId", HanvonTcpServer.config.getSchoolId());
        parameters.put("schoolName", HanvonTcpServer.config.getSchoolName());
        parameters.put("sn", sn);
        return parameters;
    }

    /**
     * 服务器回应
     *
     * @param session
     */
    @Override
    public void render(IoSession session) {
        session.write("Return(result=\"success\")");
    }
}
